import matplotlib.pyplot as plt
import numpy as np

"""
点的表示
'.'          point marker
','          pixel marker
'o'          circle marker
'v'          triangle_down marker
'^'          triangle_up marker
'<'          triangle_left marker
'>'          triangle_right marker
'1'          tri_down marker
'2'          tri_up marker
'3'          tri_left marker
'4'          tri_right marker
's'          square marker
'p'          pentagon marker
'*'          star marker
'h'          hexagon1 marker
'H'          hexagon2 marker
'+'          plus marker
'x'          x marker
'D'          diamond marker
'd'          thin_diamond marker
'|'          vline marker
'_'          hline marker

线条的属性
'-'          solid line style 实线
'--'         dashed line style 虚线
'-.'         dash-dot line style 点画线
':'          dotted line style 点线

线条的颜色
'b'          blue 蓝
'g'          green 绿
'r'          red 红
'c'          cyan 蓝绿
'm'          magenta 洋红
'y'          yellow 黄
'k'          black 黑
'w'          white 白

"""
x = np.linspace(-10, 10, 1000)
plt.rcParams['font.sans-serif'] = ['KaiTi']  # 防止乱码
plt.rcParams['axes.unicode_minus'] = False  # 解决保存图像是负号'-'显示为方块的问题

px = 5
py = 25
plt.plot(x, x ** 2, '-g', px, py, 'ro', label='y=x**2')
# plt.title('\n$y = x^2$')  # 标题
plt.xlabel('X轴')  # X轴名称
plt.ylabel('Y轴')  # Y轴名称
plt.grid(True)  # 添加网状线

plt.text(0, 85, "$y = x^2$", fontsize=30, color='blue', ha="center")
# plt.text(px - 1, 23, "标记点", fontsize=15, ha="right", weight="heavy")
plt.annotate("标记点", xy=(px, py), xytext=(0, py),  # 箭头指示
             color="green", weight="heavy", fontsize=14,
             arrowprops={"facecolor": "lightgreen"})
plt.text(px, py, "x = %0.2f\ny = %0.2f" % (5, 25), rotation=50, color='gray')

# plt.legend()
plt.show()
